﻿using System;
using HigLabo.Net.Extensions;

namespace HigLabo.Net.WindowsLive
{
    /// <summary>
    /// 
    /// </summary>
    public class Calendar : ResponseObject
    {
        /// <summary>
        /// 
        /// </summary>
        public String ID { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public String Name { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public String Description { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public DateTimeOffset? CreatedTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public DateTimeOffset? UpdatedTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public IdName From { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public Boolean IsDefault { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public String SubscriptionLocation { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public String Permissions { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsontext"></param>
        public Calendar(String jsontext)
        {
            this.SetProperty(jsontext);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsontext"></param>
        public override void SetProperty(String jsontext)
        {
            var d = this.SetData(jsontext);
            this.ID = d.ToString("id");
            this.Name = d.ToString("name");
            this.Description = d.ToString("description");
            this.CreatedTime = d.ToDateTimeOffset("created_time");
            this.UpdatedTime = d.ToDateTimeOffset("updated_time");
            if (d.ContainsKey("from") == true)
            {
                this.From = new IdName(d.ToString("from"));
            }
            this.IsDefault = d.ToBoolean("is_default") ?? false;
            this.SubscriptionLocation = d.ToString("subscription_location");
            this.Permissions = d.ToString("permissions");
        }
    }
}
